package com.example.devicemanage.dao;

import com.example.devicemanage.entity.Admin;
import com.example.devicemanage.entity.Equip;
import com.example.devicemanage.entity.Regist;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EquipMapper {
    //将sql语句注解写到函数上，自动封装结果
    @Select("SELECT * FROM equip WHERE state !=2")
    List<Equip> queryAllEquip();

    @Select("SELECT * FROM equip WHERE eid=#{eid}")
    Equip querySingle(String eid);

    @Select("SELECT * FROM equip WHERE ename=#{ename} and state !=2")
    Equip queryEquipByname(String ename);

    @Delete("DELETE FROM equip WHERE eid=#{eid}")
    int deleteEquipByname(String eid);

    @Update("UPDATE equip SET ename=#{0},category=#{1},model=#{2},spec=#{3},num=#{4},pdate=#{5},manufacturer=#{6},agent=#{7} WHERE eid=#{8}")
    int saveEq(String ename, String category, String model, String spec, int num, String pdate, String manufacturer, String agent, String eid);

    @Update("UPDATE equip SET state= 1 WHERE eid=#{eid}")
    int updateSta(String eid);

    @Update("UPDATE equip SET state= 0 WHERE eid=#{eid}")
    int updateStaTwo(String eid);

    @Update("UPDATE equip SET state= 2 WHERE eid=#{eid}")
    int updateStaThree(String eid);

    @Insert("insert into equip(category,ename,eid,model,spec,price,num,pdate,manufacturer,agent,state) value(#{category},#{ename},#{eid},#{model},#{spec},#{price},#{num},#{pdate},#{manufacturer},#{agent},'0')")
    int regist_intoEquip(Regist regist);
}
